/*

	Portfolio scrolling jQuery by Myo Kyaw Htun

	the action.js uses jQuery scrollTo plugin to scroll to the #ID of clients image

	switchClient() function scroll to each page every 2500 set by the Timer 

	

*/


$(document).ready(function(){
	$('#paging ul li a').click(function (event) {
     
     	// prevent default
     	event.preventDefault();
     	
    		//reset all the items
    		$('#paging ul li a').removeClass('active');
         
    		//set current item as active
    		$(this).addClass('active'); 
         
    	
       // scroll to ID .... value defined in 'rel'
        $('#clientsWrap').scrollTo($(this).attr('rel'),800);
       
         
	});

		$('#clientsWrap').scrollTo('#page-5',3000);  // Show the last page on load as default
		$('#theLastPage').addClass('active'); 	// set active bullet

	
});

	var timer = setInterval(switchClient, 4000); // 2500 timer

	var counter = 0;

	var pg = '#page-'; // ID of Client Images
	var bu = '.bullet-'; // Buttet class

	function switchClient()
	{
		if (counter ==0) { 
			counter++; return; 
		}
		var	pageNum = pg + counter;
		var bulNum = bu + counter;

		$('#clientsWrap').scrollTo(pageNum, 800);
		//reset all the items
    		$('#paging ul li a').removeClass('active');
         
    		//set current item as active
    		$(bulNum).addClass('active'); 
		if(counter == 5) {
			 counter = 0 ; 
		}		
		counter ++ ;
	}
